package com.zk.monitormanagement.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.zk.monitormanagement.R;
import com.zk.monitormanagement.activity.realplay.EZRealPlayActivity;
import com.zk.monitormanagement.base.BaseActivityImp;
import com.zk.monitormanagement.utils.SharedPreferUtils;

import butterknife.BindView;

public class SplashActivity extends BaseActivityImp {

    @BindView(R.id.iv_splash_logo)
    ImageView ivSplashLogo;
    @BindView(R.id.splash_root)
    RelativeLayout splashRoot;

    private AlphaAnimation animation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        animation = new AlphaAnimation(0.3f, 1.0f);
        animation.setDuration(1500);
        splashRoot.startAnimation(animation);
        animation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                // TODO Auto-generated method stub
                String token=SharedPreferUtils.getInstance().get(SplashActivity.this,"token");
                if (!TextUtils.isEmpty(token.trim())) {
                    startActivity(new Intent(SplashActivity.this, EZRealPlayActivity.class));
                    finish();
                } else {
                    startActivity(new Intent(SplashActivity.this, LoginActivity.class));
                    finish();
                }
            }
        });
    }

    @Override
    protected void initEvent() {

    }
}
